﻿using System;
using System.Configuration;
using System.Diagnostics.CodeAnalysis;
namespace BGShell.Configuration
{
    [SuppressMessage("Microsoft.Design", "CA1010:CollectionsShouldImplementGenericInterface")]
    [ConfigurationCollection(typeof(BGShellAddInElement), CollectionType = ConfigurationElementCollectionType.AddRemoveClearMap)]
    public sealed class BGShellAddInElementCollection : ConfigurationElementCollection
    {
        public BGShellAddInElement this[int index]
        {
            get { return (BGShellAddInElement)BaseGet(index); }
            set
            {
                if (BaseGet(index) != null)
                {
                    BaseRemoveAt(index);
                }

                BaseAdd(index, value);
            }
        }

        public new BGShellAddInElement this[string name]
        {
            get { return (BGShellAddInElement)BaseGet(name); }
        }

        protected override ConfigurationElement CreateNewElement()
        {
            return new BGShellAddInElement();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((BGShellAddInElement)(element)).Key;
        }
    }
}